//package cn.tedu.store.util;
//
//import cn.hutool.json.JSONUtil;
//import cn.tedu.store.entity.Repair;
//import cn.tedu.store.service.IRepairService;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.BeansException;
//import org.springframework.context.ApplicationContext;
//import org.springframework.context.ApplicationContextAware;
//import org.springframework.data.redis.core.StringRedisTemplate;
//import org.springframework.scheduling.annotation.EnableAsync;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import java.text.SimpleDateFormat;
//import java.util.Date;
//import java.util.List;
//
///**
// * 定时任务的使用
// * @author fan
// **/
//@Component("Task")
//@EnableScheduling
//@EnableAsync
//@Slf4j
//public class Task  implements ApplicationContextAware {
////    /**
////     * 异步线程池设置
////     * 如果所有的任务都使用异步，线程池执行的话，可以不配置同步任务线程池。但是使用异步需要注意的是异步线程池的大小配置。异步的线程池默认是无上限的开启线程数的。
////     * @return
////     */
////    @Bean
////    SimpleAsyncTaskExecutor simpleAsyncTaskExecutor(){
////        SimpleAsyncTaskExecutor simpleAsyncTaskExecutor = new SimpleAsyncTaskExecutor();
////        simpleAsyncTaskExecutor.setConcurrencyLimit(7);		//设置最大并行数
////        simpleAsyncTaskExecutor.setDaemon(true); 	//设置为守护线程
////        return  simpleAsyncTaskExecutor;
////    }
//
//    @Resource
//    StringRedisTemplate stringRedisTemplate;
//    @Resource
//    IRepairService repairService;
////    @Scheduled(cron="0 */1 * * * ? ")   //每5秒执行一次
//    public void user() throws Exception {
//        System.out.println(new Date());
//        Date start = new Date();start.setHours(0);start.setMinutes(0); start.setSeconds(0);
//        Date end = new Date();end.setHours(23);end.setMinutes(59); end.setSeconds(59);
//        SimpleDateFormat toDay = new SimpleDateFormat("yyyy-MM-dd");
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        List<Repair> repairs  = repairService.selectByToDateRepairAll(sdf.format(start),sdf.format(end));
////
//        repairs.forEach(s->stringRedisTemplate.opsForList().leftPush("weixiu", JSONUtil.toJsonPrettyStr(s)));
//        repairService.automaticDispatch(repairs,sdf.format(start),sdf.format(end));
//
//    }
//
//    /**
//     * 每五秒执行一次
//     */
//    @Scheduled(cron = "0 35 8 * * ?")
//    private void printNowDate() {
//    repairService.send();
//    }
//
//
//
//    private static ApplicationContext context;
//    @Override
//    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
//        context = applicationContext;
//    }
//    public static ApplicationContext getApplicationContext() { return context;}
//    public static Object getBean(String name) {return getApplicationContext().getBean(name); }
//}
